package cn.iocoder.yudao.module.xkfz.controller.admin.excel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.xkfz.controller.admin.excel.result.CommonExcelResult;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.TechnologicalOutputSci;
import cn.iocoder.yudao.module.xkfz.domain.excel.po.TechnologicalOutputSciPo;
import cn.iocoder.yudao.module.xkfz.service.excel.TechnologicalOutputSciService;
import cn.iocoder.yudao.module.xkfz.util.ExcelHeaderExtractor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


/**
 * @Description TODO
 * @Author ZWC
 * @Date 2024/5/13 13:38
 */
@RestController
@RequestMapping("technologicalOutputSci")
public class TechnologicalOutputSciController {

    @Autowired
    private TechnologicalOutputSciService technologicalOutputSciService;

    @PostMapping("importTechnologicalOutputSci")
    public CommonResult<Boolean> importTechnologicalOutputSci(@RequestParam("file") MultipartFile file,@RequestParam("year")  String year
            ,@RequestParam("indexId")  String indexId) throws IOException {
        List<TechnologicalOutputSci> list = ExcelUtils.read(file, TechnologicalOutputSci.class);
        return success(technologicalOutputSciService.importTechnologicalOutputSci(list, year, indexId));
    }

    @GetMapping("selectPage")
    public CommonExcelResult<PageResult<TechnologicalOutputSci>>  selectPage (TechnologicalOutputSciPo reqVO){
        List<HashMap<String, String>> headerList = ExcelHeaderExtractor.getHeaderList(TechnologicalOutputSci.class);
        return CommonExcelResult.success(technologicalOutputSciService.selectPage(reqVO),headerList);
    }
    @PostMapping("insertTechnologicalOutputSci")
    public CommonResult<Boolean> insertTechnologicalOutputSci(TechnologicalOutputSci technologicalOutputSci){
        return success(technologicalOutputSciService.insertTechnologicalOutputSci(technologicalOutputSci));
    }
    @PostMapping("updateTechnologicalOutputSci")
    public CommonResult<Boolean> updateTechnologicalOutputSci(TechnologicalOutputSci technologicalOutputSci){
        return success(technologicalOutputSciService.updateTechnologicalOutputSci(technologicalOutputSci));
    }

    @PostMapping("deleteTechnologicalOutputSci")
    public CommonResult<Boolean> deleteTechnologicalOutputSci(String id){
        return success(technologicalOutputSciService.deleteTechnologicalOutputSci(id));
    }

}
